package two;


import java.util.Arrays;
import java.util.Scanner;

public class test17088 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i]=scanner.nextInt();
        }
        int a=array[0];
        int b=0;
        int j=0;
        Arrays.sort(array);
        for (int i = 0; i < array.length-1; i++) {
            if(array[i]==array[i+1]){
                j++;
            }else {
                if(j>b){
                    a=array[i];
                    b=j;
                }
                j=0;
            }
        }
        b++;
        System.out.println(a+" "+b);
    }
}
